package com.syf.controller.RJController;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.syf.cmd.AuditIdCmd;
import com.syf.cmd.CompanyApplyCmd;
import com.syf.domain.SysUser;
import com.syf.domain.store.BsCompanyApply;
import com.syf.domain.store.BsCompanyAudit;
import com.syf.model.R;
import com.syf.service.BsCompanyAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author syf
 * @create 2022-02-08 9:15
 */
@RestController
@RequestMapping("/companyAudit")
@Api(tags = "审核软件厂商")
public class BsCompanyAuditController {

    @Autowired
    private BsCompanyAuditService bsCompanyAuditService;


    /**
     * 审核软件厂商:
     *      添加一个审核记录
     *      修改申请表(厂商)状态
     *      创建一个用户，设置权限
     *      使用MQ异步发生邮箱给厂商
     */
    @PostMapping("/audit")
    @CrossOrigin
    @ApiOperation(value = "审核软件厂商")
    public R auditCompany(@RequestBody @Validated BsCompanyAudit bsCompanyAudit){
        boolean save = bsCompanyAuditService.auditCompany(bsCompanyAudit);
        if(save){
            return R.ok("新增成功") ;
        }
        return  R.fail("新增失败") ;
    }


    @PostMapping("/companyAuditDetails")
    @CrossOrigin
    @ApiOperation(value = "查看厂商--审核详细")
    public R<BsCompanyAudit> applyDetails(@RequestBody AuditIdCmd auditIdCmd){
        return R.ok(bsCompanyAuditService.getById(auditIdCmd.getAuditId())) ;
    }


}
